from pyramid.config import Configurator
from sqlalchemy import engine_from_config

from fun.models import initialize_sql

import mako 

def main(global_config, **settings):
    """ This function returns a Pyramid WSGI application.
    """
    engine = engine_from_config(settings, 'sqlalchemy.')
    initialize_sql(engine)
    config = Configurator(settings=settings)
    #config = Configurator(settings={'mako.directories':['fun:templates']})
    #config.mako_renderer_factory  = ['fun:templates']
    #config.add_renderer('.mako', 'pyramid.mako_templating.renderer_factory')
    config.add_static_view('static', 'fun:static')
    config.add_route('home', '/', view='fun.views.my_view',
                     view_renderer='templates/mytemplate.pt')
    config.add_route('highcharts', '/highcharts', view='fun.views.highcharts')
    #config.add_route('mako_demo', '/mako_demo', view='fun.views.mako_demo')
    return config.make_wsgi_app()


